package org.linlinjava.litemall.db.service;

import com.github.pagehelper.PageHelper;
import org.apache.ibatis.annotations.Param;
import org.linlinjava.litemall.db.dao.AgedmallAgentSettleDetailMapper;
import org.linlinjava.litemall.db.dao.app.AppAgentMapper;
import org.linlinjava.litemall.db.domain.AgedmallAgentSettleDetail;
import org.linlinjava.litemall.db.domain.LitemallOrderGoods;
import org.linlinjava.litemall.db.vo.app.AppAgentSettleDetail;
import org.linlinjava.litemall.db.vo.app.ProxyMoneyVo;
import org.linlinjava.litemall.db.vo.app.ProxyOrderVo;
import org.linlinjava.litemall.db.vo.app.SettleStatisticsVo;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.math.BigDecimal;
import java.time.LocalDateTime;
import java.util.List;

@Service
public class AgedmallAgentSettleDetailService {
    @Resource
    private AgedmallAgentSettleDetailMapper agedmallAgentSettleDetailMapper;
    @Resource
    private AppAgentMapper appAgentMapper;

    public List<AppAgentSettleDetail> list(Integer userId, String keyword, Integer proxyStatus, String subOrderType, String year, String month, Integer page, Integer limit) {
        PageHelper.startPage(page, limit);
        return appAgentMapper.getSettleList(userId, keyword, proxyStatus, subOrderType, year, month);
    }

    public List<SettleStatisticsVo> getSettleStatisticsVo(Integer userId, Integer year) {
        return appAgentMapper.getSettleStatisticsVo(userId, year);
    }

    public BigDecimal getSettleByYearMonth(Integer userId, Integer year, Integer month) {
        return appAgentMapper.getSettleByYearMonth(userId, year, month);
    }

    public List<ProxyMoneyVo> getProxyMoneyVoList(Integer userId, Integer year, Integer month, Byte item) {
        return appAgentMapper.getProxyMoneyVoList(userId, year, month, item);
    }

    public List<ProxyOrderVo> getProxyOrderVoList(Integer userId, Integer year, Integer month, Byte item) {
        return appAgentMapper.getProxyOrderVoList(userId, year, month, item);
    }

    public void save(AgedmallAgentSettleDetail agedmallAgentSettleDetail) {
        agedmallAgentSettleDetail.setAddTime(LocalDateTime.now());
        agedmallAgentSettleDetail.setUpdateTime(LocalDateTime.now());
        agedmallAgentSettleDetailMapper.insertSelective(agedmallAgentSettleDetail);
    }

    public List<LitemallOrderGoods> getSettleOrderGoods(Integer orderId, Integer proxyStatus) {
        return appAgentMapper.getSettleOrderGoods(orderId, proxyStatus);
    }

    public List<LitemallOrderGoods> getCustomerInfo(Integer parentId,Integer orderId){
        return appAgentMapper.getCustomerInfo(parentId,orderId);
    }
}
